package com.scenery.services;


import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import android.widget.Toast;

/**
 * 系统设置
 * SharedPreferences类参考
 * http://developer.android.com/reference/android/content/SharedPreferences.html
 * 
 * Using Shared Preferences
   http://developer.android.com/guide/topics/data/data-storage.html#pref
   
   Android数据的四种存储方式SharedPreferences、SQLite、Content Provider和File （三） —— SharePreferences 
   
   http://www.cnblogs.com/wisekingokok/archive/2011/09/16/2177833.html
 * **/
public class SetManager {
	private final String TAG = SetManager.class.getSimpleName();
	private final static String PREFS_NAME = "scenery_set";
	
	private final static String WWW_IP = "WWW_IP";//ip
	private final static String WWW_PORT = "WWW_PORT";//聊天服务器端口
	private final static String WEB_SERVERPORT = "WEB_SERVERPORT";//web服务器端口
	private final static String USER_ID = "USER_ID";//用户id
	private Context context;
	private SharedPreferences settings;

	public SetManager(Context context) {
		this.context = context;
		settings = context.getSharedPreferences(PREFS_NAME, 0);
	}

	public void save( String www_ip, String www_port,String user_id,String web_serverPort)

	{
		Log.d(TAG, www_ip+","+www_port+","+user_id+","+web_serverPort);
		SharedPreferences.Editor editor = settings.edit();
	
		editor.putString(WWW_IP, www_ip);
		editor.putString(WWW_PORT, www_port);
		editor.putString(USER_ID, user_id);
		editor.putString(WEB_SERVERPORT, web_serverPort);
		editor.commit();
	}

	
	public String getIp()
	{
	
		String ip=settings.getString(WWW_IP, "");			
		return ip;
	}
	public String getUserId()
	{
		String ip=settings.getString(USER_ID, "");			
		return ip;
	}
	public String getPort()
	{
	
		String ip=settings.getString(WWW_PORT, "");
		
	
		return ip;
	}

	public  String getWebServerport() {
		String value= settings.getString(WEB_SERVERPORT, "");
		Log.d(TAG, "getWebServerport:"+value);
		return value;
	}
	
}
